home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 626-650 / 641 / tlog / findkey.tlog < prev    next >
Text File  |  1995-03-15  |  3KB  |  116 lines

  1. /*
  2.  * FindKey.tlog
  3.  * AREXX report for TLog that prints misc. data for all entries with
  4.  * SearchKey as a substring of the key field.
  5.  */
  6.  
  7.  
  8. /* The key to search for is the 1st parameter */
  9. PARSE UPPER ARG SearchKey
  10.  
  11.  
  12.  
  13. OPTIONS RESULTS
  14. OPTIONS FAILAT 10
  15. SIGNAL ON ERROR
  16.  
  17. /* add the necessary libraries */
  18. IF(~EXISTS("libs:rexxsupport.library")|~EXISTS("libs:rexxarplib.library")|~EXISTS("libs:screenshare.library")) THEN
  19.  DO
  20.     SAY "Couldn't find needed library (rexxsupport, rexxarplib, screenshare, or rexxmathlib)."
  21.     EXIT 20
  22.  END
  23.  
  24. IF ~SHOW('L','rexxsupport.library') THEN
  25.    CALL ADDLIB('rexxsupport.library',0,-30)
  26. IF ~SHOW('L','rexxarplib.library') THEN
  27.    CALL ADDLIB('rexxarplib.library',0,-30)
  28. IF ~SHOW('L','rexxmathlib.library') THEN
  29.    CALL ADDLIB('rexxmathlib.library',0,-30)
  30.  
  31.  
  32. /* setup the port to tlog */
  33. ADDRESS 'TLOG'
  34.  
  35.  
  36. /* Open our  window */
  37. CALL open out,"con:0/0/640/170/FindKey " || SearchKey
  38. IF ~RESULT THEN DO
  39.    SAY "Open failure ... sorry"
  40.    EXIT 10
  41. END
  42. CSI = '9B'x
  43.  
  44.  
  45.  
  46. /* use TLog dateformat MMM DD YY and grab the 1st 3 chars as the month */
  47. GetDateFormat
  48. oldFormat = RESULT
  49. DateFormat 4
  50.  
  51. /*
  52.  *  IF you have been making entries into the data base, it is best to
  53.  *  flush its buffers by doing a close first
  54.  */
  55. CloseDB
  56.  
  57.  
  58. /* Open the data base and mark the end record */
  59. OpenDB
  60. LastRec
  61. lastDataRecord = RESULT
  62.  
  63.  
  64. CALL SCREENTOFRONT()
  65.  
  66. CALL writech out, "TLog records containing subkey: "
  67. CALL writech out, CSI'0;33;40m'
  68. CALL writech out, SearchKey
  69. CALL writeln out, CSI'0;31;40m'
  70.  
  71. /* get the first record and its data */
  72. FirstRec
  73.  
  74. /* Now loop forever, or until nextrec yields the last record */
  75. DO FOREVER
  76.     /* After the date, the fields in a record are delineated by spaces */
  77.     PARSE VAR RESULT '"' dbdate '"' dbheart dbdist dbtime dbweight dbtemp dbkey
  78.     PARSE UPPER VAR dbkey testkey '.'
  79.     /* Is the SearchKey is a substring of the current key? */
  80.     IF  INDEX(testkey,  SearchKey, 1) ~= 0 THEN DO
  81.         /* here you can do what you want with the found record */
  82.         CALL writeln out, "Date " dbdate " Distance "  dbdist " Time "  dbtime " Key " dbkey
  83.     END
  84.  
  85.     IF  RESULT = lastDataRecord THEN BREAK
  86.     NextRec
  87. END
  88.  
  89. /* restore the date format */
  90. DateFormat oldFormat
  91.  
  92.  
  93. CALL writeln out, " "
  94. /* put up prompt in color 2 */
  95. CALL writech out, CSI'0;32;40m'
  96. CALL writeln out, "Press <Return> to EXIT"
  97. CALL readln out
  98.  
  99. CALL SCREENTOBACK()
  100.  
  101. EXIT
  102.  
  103.  
  104. ERROR:
  105.  
  106. CALL writeln out, " "
  107. /* put up prompt in color 2 */
  108. CALL writech out, CSI'0;32;40m'
  109. CALL writeln out, "Press <Return> to EXIT"
  110. CALL readln out
  111.  
  112. CALL SCREENTOBACK()
  113.  
  114. EXIT RC
  115.  
  116.